<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of BUIScreenListLayout
 *
 * @author jianfeng
 */
class BUIViewLayout {

    const LIST_LAYOUT = 'list';
    const INLINE_LAYOUT = "in-line";

    //put your code here
    private $viewItems = array();
    private $layout = 'list';

    public function __construct($layout = 'list') {
        if ($layout != NULL)
            $this->layout = $layout;
    }

    public function addViewItem($view, $viewData = null, $viewPath = NULL) {

        if ($viewPath == NULL) {
            $viewPath = Blyn::app()->getAppUI()->getUINodeFilesPath();
            if (!file_exists(yii::getPathOfAlias($viewPath . '.' . $view) . '.php')) {
                $viewPath = Blyn::app()->getUIManager()->viewPath;
            }
        }

        array_push($this->viewItems, array('view' => $viewPath . "." . $view, 'data' => $viewData));
    }

    public function addViewLayout($layoutView, $layoutViewData, $viewPath = NULL) {
        array_push($this->viewItems, array('view' => $layoutView, 'data' => $layoutViewData));
    }

    public function getLayoutData() {
        return array('items' => $this->viewItems);
    }

    public function getLayoutView() {
        if ($this->layout == self::LIST_LAYOUT) {
            return 'listLayoutView';
        }

        if ($this->layout == self::INLINE_LAYOUT) {
            return 'inlineLayoutView';
        }
    }

}

?>
